<?php

declare (strict_types=1);

namespace App\Model;

/**
 * @property int $id 认证信息ID
 * @property int $shop_id 店铺ID
 * @property string $fullname 完整名称：个人姓名 || 企业名称
 * @property string $cert_number 证件号
 * @property int $cert_type 证件类型：1个人身份证号 2企业唯一认证号
 * @property int $create_time 信息提交时间
 * @property int $update_time 更新时间
 * @property int $user_id 用户ID
 */
class FlyShopCertificate extends Model
{
    const CERT_TYPE_OWN = 1;// 个人
    const CERT_TYPE_COM = 2;//企业

    /**
     * @var bool
     */
    public $timestamps = false;

    /**
     * @var string
     */
//    protected $dateFormat = 'U';

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'fly_shop_certificate';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */

    protected $casts = [
        'id' => 'integer',
        'shop_id' => 'string',
        'cert_type' => 'integer',
        'create_time' => 'datetime',
        'update_time' => 'datetime',
        'user_id' => 'string'
    ];

    public function with_certs_file()
    {
        return $this->hasMany(FlyShopCertificateAtt::class, 'cert_id', 'id')
            ->leftJoin('fileinfo as f', 'fly_shop_certificate_att.fileinfo_id', '=', 'f.fileinfo_id');
    }
}